set(TARGET_NAME IonexFileReader)

find_package(pegtl CONFIG REQUIRED)

add_compile_definitions(IONEXFILEREADER_LIB)

file(GLOB HEADERS "*.h")
file(GLOB SOURCES "*.cpp")
file(GLOB PRIVATES "Private/*.h" "Private/*.cpp")

source_group("Headers" FILES ${HEADERS})
source_group("Sources" FILES ${SOURCES})
source_group("Private" FILES ${PRIVATES})

if(NOT ${IONEX_BUILD_STATIC})
    set(_BUILD_TYPE SHARED)
endif()

add_library(${TARGET_NAME} ${_BUILD_TYPE} ${HEADERS} ${SOURCES} ${PRIVATES})

target_link_libraries(${TARGET_NAME} PRIVATE taocpp::pegtl)

set_target_properties(${TARGET_NAME} PROPERTIES PUBLIC_HEADER "${HEADERS}")
export_install_target(${TARGET_NAME} ${INSTALL_INCLUDEDIR} ${INSTALL_LIBRARYDIR} ${INSTALL_BINDIR})
